import 'dart:io';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:matisse_android_plugin/export_matisse.dart';
import 'package:multi_image_picker/multi_image_picker.dart';
import 'package:path_provider/path_provider.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  var url;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              GestureDetector(
                  onTap: () async {
                    List<String> resultList = await MatisseUtil.selectPhoto(
                        context: context, maxSize: 2);
                    setState(() {
                      url = resultList.elementAt(0);
                    });
                  },
                  child: RaisedButton(
                      child: Text(
                    '裁剪测试',
                    style: TextStyle(color: Colors.white),
                  ))),
              Image.file(
                File(url ?? ""),
                width: 300,
                height: 300,
              )
            ],
          ),
        ),
      ),
    );
  }
}
